<?php
require_once 'menu.php';
require_once 'Clases/conectar.php';

//Seleccionamos los registros de la tabla
$query = pg_query(conectar::conecta(), "SELECT * FROM empleados");

$empleados = array(
    "1" => "ID",
    "2" => "Nombre",
    "3" => "IDTipo",
    "4" => "Edad"
);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Modificar Empleado</title>

        <link rel="stylesheet" type="text/css" href="css//jquery.dataTables.css">
            <link rel="stylesheet" type="text/css" href="css//shCore.css">
                <link rel="stylesheet" type="text/css" href="css//demo.css">

                    <script type="text/javascript" src="js//jquery.js"></script>
                    <script type="text/javascript" src="js//jquery.jeditable.js"></script>


                    <script type="text/javascript" language="javascript" src="js//jquery.dataTables.js"></script>
                    <script type="text/javascript" language="javascript" src="js//shCore.js"></script>
                    <script type="text/javascript" language="javascript" src="js//demo.js"></script>

                    <script type="text/javascript" language="javascript" class="init">


                        $(document).ready(function() {
                            var table = $('#example').DataTable();

                            $('#example tbody').on('click', 'tr', function() {
                                $(this).toggleClass('selected');
                            });

                            $('#button').click(function() {
                                alert(table.rows('.selected').data().length + ' row(s) selected');
                            });
                        });


                    </script>

                    </head>
                    <body class="dt-example">
                        <div id="area" class="contenido"> 
                            <fieldset id="content">
                                <legend><h5 style="color:black">Lista De Empleados</h5></legend>
                                <table id="example" class="display" cellspacing="0" width="100%">
                                    <thead>
                                        <tr class="head">
                                            <th>ID</th>
                                            <th>Nombre</th>
                                            <th>Cargo Empleado</th>
                                            <th>Edad</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        while ($row = pg_fetch_array($query)) {
                                            $id = $row['idempleado'];
                                            ?>
                                            <tr>
                                                <td><div class="noeditable" id="idempleado-<?php echo $id ?>"><?php echo $row['idempleado'] ?></div></td>
                                                <td align="center"><div class="text" id="nombre-<?php echo $id ?>"><?php echo $row['nombre'] ?></div></td>


                                                <?php
                                                switch ($row['idtipo_empleado']) {
                                                    case 1;
                                                        ?> <td align="center"><div class="select" id="idtipo_empleado-<?php echo $id ?>">Vendedor</td>

                                                        <?php
                                                        break;

                                                    case 2;
                                                        ?> <td align="center"><div class="select" id="idtipo_empleado-<?php echo $id ?>">Mecanico</td>


                                                        <?php
                                                        break;

                                                    case 3;
                                                        ?> <td align="center"><div class="select" id="idtipo_empleado-<?php echo $id ?>">Administrador</td>



                                                        <?php
                                                        break;
                                                }
                                                ?>







                                                <td align="center"><div class="text" id="fecha-<?php echo $id ?>"><?php echo $row['fecha'] ?></div></td>
                                            </tr>
                                            <?php
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </fieldset>
                        </div>
                    </body>
                    </html>